package com.cts.controller.admin;

import com.cts.model.dto.LogDTO;
import com.cts.model.vo.PageResultVO;
import com.cts.model.vo.Result;
import com.cts.service.LoginLogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @projectName: CBlog
 * @package: com.cts.controller.admin
 * @className: LoginLogController
 * @author: chentongsheng
 * @description: TODO
 * @date: 2023/4/6 21:42
 * @version: 1.0
 */
@RestController
@RequestMapping("/admin")
public class LoginLogController {

    @Autowired
    LoginLogService loginLogService;

    @ApiOperation("获取登陆日志")
    @PostMapping("/getLoginLog")
    public Result getLoginLog(@RequestBody LogDTO logDTO) {
        PageResultVO loginLog = loginLogService.getLoginLog(logDTO);
        return Result.ok("请求成功", loginLog);
    }

    @ApiOperation("删除登陆日志")
    @PostMapping("/deleteLoginLog")
    public Result deleteLoginLog(@RequestParam Long id) {
        Boolean flag = loginLogService.removeById(id);
        if(flag){
            return Result.ok("删除成功");
        }
        return Result.error("删除失败");
    }
}
